Web Coding & Development All-in-One For Dummies by Paul McFedries

Web Coding & Development All-in-One For Dummies by Paul McFedries

Author:Paul McFedries
Language: eng
Format: epub
ISBN: 9781119473794
Publisher: Wiley
Published: 2018-05-08T00:00:00+00:00


Preventing the default event action

Some events come with default actions that they perform when the event fires. For example, a link's click event opens the target URL, whereas a form’s submit event sends the form data to a script on the server. Most of the time these default actions are exactly what you want, but that's not always the case. For example, you might want to intercept a link click to perform some custom action, such as displaying a menu. Similarly, rather than letting the browser submit a form, you might prefer to massage the form data and then send the data via your script.

For these and many similar situations, you can tell the web browser not to perform an event’s default action by running the Event object’s preventDefault() method:

event.preventDefault();

event: A reference to the Event object that jQuery creates when an event fires



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.